<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<!--view视图-->
<div id="app">
    <p>currentTime1={{currentTime1()}}</p>
    <p>currentTime2={{currentTime2}}</p>
</div>


<!--1.导入vue.js-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    var vm= new Vue({
        el: "#app",
        data: {
            message: "hello",
        },
        methods: {
            currentTime1: function () {
                return Date.now();//返回当前时间
            }
        },
        computed: {//计算属性 methods和computed中的方法重名后，只会调用methods的方法
            currentTime2: function () {
                this.message;   //当缓存中有数据更新，就重新存储
                return Date.now();//返回当前时间
            }
        }
    });
</script>
</body>
</html>